#pragma once

#include <fstream>
#include <sstream>
#include <iostream>

#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>


struct Net_config
{
	float confThreshold; // Confidence threshold
	float nmsThreshold;  // Non-maximum suppression threshold
	int inpWidth;  // Width of network's input image
	int inpHeight; // Height of network's input image
	std::string classesFile;
	std::string modelConfiguration;
	std::string modelWeights;
	std::string netname;
	std::string target;
};

struct DetectObjsInfo
{
	float times;
	std::vector<std::string> objs;
	std::vector<float> scores;
	std::string imgfile;
	std::string recfile;
	std::string timestamp;
	cv::Mat cvimg;
};

class YOLO
{
	public:
		YOLO(Net_config config);
		DetectObjsInfo* detect(cv::Mat& frame);

	private:
		float confThreshold;
		float nmsThreshold;
		int inpWidth;
		int inpHeight;
		char netname[20];
		std::vector<std::string> classes;
		cv::dnn::Net net;
		void postprocess(cv::Mat& frame, const std::vector<cv::Mat>& outs, DetectObjsInfo* info);
		std::string drawPred(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame);
};
